# Maintainer: Christian Heusel <gromit@archlinux.org>
# Contributor: éclairevoyant
# Contributor: nullgemm <nullgemm@mailbox.org>

pkgname=ly
pkgver=0.6.0
pkgrel=1
_tag=1c2be475ad09af18e632609c779d508e7fb866f9
pkgdesc="TUI display manager"
arch=(loong64 x86_64)
url="https://github.com/fairyglade/ly"
license=('custom:WTFPL')
depends=(pam)
makedepends=(git libxcb)
optdepends=('xorg-xauth: for X server sessions'
            'libxcb: for X server sessions')
backup=(etc/$pkgname/{config.ini,wsetup.sh,xsetup.sh})
source=("git+$url.git#tag=$_tag"
        "git+https://github.com/nullgemm/argoat.git"
        "git+https://github.com/nullgemm/configator.git"
        "git+https://github.com/nullgemm/dragonfail.git"
        "git+https://github.com/nullgemm/termbox_next.git")
b2sums=('SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP')

prepare() {
    cd "$pkgname"
    git submodule init

    git config submodule.sub/argoat.url "$srcdir/argoat"
    git config submodule.sub/configator.url "$srcdir/configator"
    git config submodule.sub/dragonfail.url "$srcdir/dragonfail"
    git config submodule.sub/termbox_next.url "$srcdir/termbox_next"

    git -c protocol.file.allow=always submodule update
}

build() {
    make -C "$pkgname"
}

package() {
    cd "$pkgname"
    # we install the binary as ly-dm because of the conflict with python-ly
    make DESTDIR="$pkgdir" NAME=ly-dm install installsystemd
    sed -i "s;/usr/bin/ly;/usr/bin/ly-dm;g" "$pkgdir/usr/lib/systemd/system/ly.service"
    install -Dm644 license.md "$pkgdir/usr/share/licenses/$pkgname/WTFPL"
}
